/**
***
***************************************************************
***     Copyright (c) 2016 Queclink Ltd.
***
***         dev_comm_conf.h
***         flash device common cmd & config
***         johar.xiao
***     2017-01-09
***     head  file
***************************************************************
    FLASH 通用的操作命令和配置信息
**************************************************************
***
**/

#ifndef _DEV_COMM_CONF_H_
#define _DEV_COMM_CONF_H_

#ifdef __cplusplus
    extern "{"
#endif

/*flash 命令表 ---------------------------------------------------------------*/
#define CMD_WREN                    0x06
#define CMD_WRDI                    0x04
#define CMD_RDSR                    0x05
#define CMD_READ_ID                 0x9F
#define CMD_WRSR                    0x01
#define CMD_WRLR                    0xE5
#define CMD_RDLR                    0xE8
#define CMD_READ                    0x03

#define CMD_FAST_READ               0x0B
#define CMD_RDSFDB                  0x5A
#define CMD_RES                     0xAB        //device ID
#define CMD_REMS                    0x90        //manufacturer ID\ device ID
#define CMD_DREAD                   0x3B

#define CMD_PAGE_PROG               0x02
#define CMD_PAGE_ERASE              0xDB
#define CMD_PAGE_WRITE              0x0A
#define FLASH_CMD_WRITE             CMD_PAGE_PROG

#define CMD_BLOCK_64k_ERASE         0xD8
#define CMD_BLOCK_32K_ERASE         0x52
#define CMD_BLOCK_ERASE             CMD_BLOCK_64k_ERASE //For M25PE16, it is the command of sector erase

#define CMD_SECTOR_ERASE            0x20        //For M25PE16, it is the command of subsector erase
#define CMD_CHIP_ERASE              0x60        //For M25PE16, it is the same meaning of bulk erase
#define CMD_DEEP_PWDN               0xB9
#define CMD_RELS_PWDN               0xAB

#define PAGE_SIZE                   0x100       /*页大小 ---------*/
#define PAGES_OF_ONE_SECTOR         0x10        /*每个扇区的总页数*/

#define ENTRY_4BYTES_MODE           0xB7
#define EXIT_4BYTES_MODE            0xE9

#define PAGE_NO_MASK                0xFFFF00
#define SECTOR_NO_MASK              0xFFF000
#define PAGE_SIZE_MASK              0x0000FF
#define SECTOR_SIZE_MASK            0x000FFF

#define DATA_HEAD_FLAG              0x55
#define DATA_TAIL_FLAG              0xAA


/******************************************************************
**@@  SIZE DEFINE ***/
#define B128_SIZE                   0x80        /** 128B        **/
#define B256_SIZE                   0x100       /** 256B    **/
#define B512_SIZE                   0x200       /** 512B    **/
#define K1_SIZE                     0x400       /** 1KB     **/
#define K2_SIZE                     0x800       /** 2KB     **/
#define K4_SIZE                     0x1000      /** 4KB     **/
#define K32_SIZE                    0x8000      /** 32KB        **/
#define K64_SIZE                    0x10000     /** 64KB        **/
#define K128_SIZE                   0x20000     /** 128KB   **/
#define K256_SIZE                   0x40000     /** 256KB   **/
#define K512_SIZE                   0x80000     /** 512KB   **/
#define M1_SIZE                     0X100000    /** 1MB     **/
#define M2_SIZE                     0x200000    /** 2MB     **/
#define M4_SIZE                     0x400000    /** 4MB     **/
#define M8_SIZE                     0x800000    /** 8MB     **/
#define M16_SIZE                    0x1000000   /** 16MB    **/
#define M32_SIZE                    0x2000000   /** 32MB    **/
#define M64_SIZE                    0x4000000   /** 64MB    **/

#ifdef __cplusplus
        }
#endif

#endif

/***    END FO FILES    **/
